package com.example.emos.api.controller.form.userform;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.*;

/**
 * @author keying
 * @create 2024--05--16
 */
@Data
@Schema(description = "添加用户表单")
public class InsertUserForm {

    //username
    @NotBlank(message = "username不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]{5,20}$", message = "用户名格式不正确")
    @Schema(description = "用户名")
    private String username;

    //password
    @NotBlank(message = "密码不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]{6,20}$", message = "密码格式不正确")
    @Schema(description = "密码")
    private String password;

    //name
    @NotBlank(message = "姓名不能为空")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,10}", message = "name内容不正确")
    @Schema(description = "姓名")
    private String name;

    //sex
    @NotBlank(message = "性别不能为空")
    @Pattern(regexp = "^男$|^女$",message = "sex内容不正确")
    @Schema(description = "性别")
    private String sex;

    //tel
    @NotBlank(message = "电话不能为空")
    @Pattern(regexp = "^1\\d{10}$",message = "tel内容不正确")
    @Schema(description = "电话")
    private String tel;

    //email
    @NotBlank(message = "邮箱不能为空")
    @Email(message = "邮箱内容不正确")
    @Schema(description = "邮箱")
    private String email;

    //hiredate
    @NotBlank(message = "hiredate不能为空")
    @Schema(description = "入职日期")
    private String hiredate;

    //role
    @NotEmpty(message = "role不能为空")
    @Schema(description = "角色")
    private Integer[] role;

    //deptId
    @Min(value = 1,message = "deptId不能小于1")
    @Schema(description = "部门")
    @NotNull(message = "deptId不能为空")
    private Integer deptId;
}
